package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveRoomFaceRecords;
import com.hiultra.archive.service.IArchiveRoomFaceRecordsService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 人员刷脸记录Controller
 *
 * @author 派大星
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/archive/ArchiveRoomFaceRecords")
public class ArchiveRoomFaceRecordsController extends BaseController {
    @Autowired
    private IArchiveRoomFaceRecordsService archiveRoomFaceRecordsService;

    /**
     * 查询人员刷脸记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveRoomFaceRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveRoomFaceRecords archiveRoomFaceRecords) {
        startPage();
        List<ArchiveRoomFaceRecords> list = archiveRoomFaceRecordsService.selectArchiveRoomFaceRecordsList(archiveRoomFaceRecords);
        for (ArchiveRoomFaceRecords item : list) {
            String pic = "data:image/png;base64," + item.getPic();
            item.setPic(pic);
        }
        return getDataTable(list);
    }

    /**
     * 导出人员刷脸记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveRoomFaceRecords:export')")
    @Log(title = "人员刷脸记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveRoomFaceRecords archiveRoomFaceRecords) {
        List<ArchiveRoomFaceRecords> list = archiveRoomFaceRecordsService.selectArchiveRoomFaceRecordsList(archiveRoomFaceRecords);
        ExcelUtil<ArchiveRoomFaceRecords> util = new ExcelUtil<ArchiveRoomFaceRecords>(ArchiveRoomFaceRecords.class);
        util.exportExcel(response, list, "人员刷脸记录数据");
    }

    /**
     * 获取人员刷脸记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveRoomFaceRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(archiveRoomFaceRecordsService.selectArchiveRoomFaceRecordsById(id));
    }

    /**
     * 新增人员刷脸记录
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveRoomFaceRecords:add')")
    @Log(title = "人员刷脸记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveRoomFaceRecords archiveRoomFaceRecords) {
        return toAjax(archiveRoomFaceRecordsService.insertArchiveRoomFaceRecords(archiveRoomFaceRecords));
    }

    /**
     * 修改人员刷脸记录
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveRoomFaceRecords:edit')")
    @Log(title = "人员刷脸记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveRoomFaceRecords archiveRoomFaceRecords) {
        return toAjax(archiveRoomFaceRecordsService.updateArchiveRoomFaceRecords(archiveRoomFaceRecords));
    }

    /**
     * 删除人员刷脸记录
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveRoomFaceRecords:remove')")
    @Log(title = "人员刷脸记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(archiveRoomFaceRecordsService.deleteArchiveRoomFaceRecordsByIds(ids));
    }
}
